home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 April
/
EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso
/
EARCD
/
comm
/
bbs
/
Hydra11s.lha
/
HBBS
/
Source
/
Doors_System
/
ModifyDIZ
/
Main.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-31
|
5KB
|
231 lines
/*
ModifyDIZ
=========
This door displays the .DIZ on the screen
the user is then asked
1) Use this DIZ
2) Enter New DIZ
3) Modify DIZ
Pressing return defaults to option 1.
Options
=======
N_ND->ActiveDoor->SystemOptions
-------------------------------
none
Door Options (Command Line)
---------------------------
2 <filename>
3 <workdir>
4 <playpen dir>
5 <filename without .extension>
6 <.extension without filename and without the .>
Note: Hey, I really couldn't think of any other settings that might be usefull..
you can even write a damn AmigaDOS script to extract file_id's with all those
parameters! hehehe
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
#include <clib/alib_protos.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#ifdef __SASC
int CXBRK(void) { return(0); }
int _CXBRK(void) { return(0); }
void chkabort(void) {}
#endif
#include <HBBS/ANSI_Codes.h>
#include <HBBS/Defines.h>
#include <HBBS/types.h>
#include <HBBS/structures.h>
#include <HBBS/hbbscommon_protos.h>
#include <HBBS/hbbscommon_pragmas.h>
#include <HBBS/Hbbsnode_protos.h>
#include <HBBS/Hbbsnode_pragmas.h>
#include <HBBS/release.h>
char *versionstr="$VER: ModifyDIZ "RELEASE_STR;
struct Library *HBBSCommonBase=NULL;
struct Library *HBBSNodeBase=NULL;
struct BBSGlobalData *BBSGlobal=NULL;
struct NodeData *N_ND=NULL;
int N_NodeNum=-1;
char outstr[1024]; // temp string for displaying text..
char filename[1024]; // temp string for displaying text..
struct List *FileID=NULL;
static VOID cleanup(ULONG num)
{
if (HBBSNodeBase)
{
HBBS_CleanUpDoor();
CloseLibrary (HBBSNodeBase);
}
if (HBBSCommonBase)
{
HBBS_CleanUpCommon();
CloseLibrary (HBBSCommonBase);
}
if (num) printf("Door Error = %d\n",num);
exit(0);
}
static VOID init(char *name)
{
if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
{
cleanup(1);
}
if (!(HBBS_InitCommon()))
{
cleanup(2);
}
if(!(HBBSNodeBase = OpenLibrary("HBBSNode.library",0)))
{
cleanup(3);
}
if (!(HBBS_InitDoor(N_NodeNum,name)))
{
cleanup(4);
}
SetProgramName(name);
}
void DisplayDIZ( void )
{
struct Node *node;
DOOR_WriteText(ANSI_RESET ANSI_FG_YELLOW " +---------------------------------------------+\r\n" ANSI_FG_WHITE);
for (node = FileID->lh_Head ; node->ln_Succ ; node =node->ln_Succ)
{
// if (strlen(node->ln_Name)>LEN_DIZWIDTH) node->ln_Name[LEN_DIZWIDTH]=0;
sprintf(outstr," %s\r\n",node->ln_Name);
DOOR_WriteText(outstr);
}
DOOR_WriteText(ANSI_RESET ANSI_FG_YELLOW " +---------------------------------------------+\r\n" ANSI_FG_WHITE);
}
void EditDIZ( void )
{
V_SMALLNUM Lines;
V_BOOL Done=FALSE;
Lines=N_ND->MaxDIZLines;
sprintf(outstr,"please enter upto %d lines to describe this file\r\n",N_ND->MaxDIZLines);
DOOR_WriteText(ANSI_RESET ANSI_FG_YELLOW " +---------------------------------------------+\r\n" ANSI_FG_WHITE);
while ((N_ND->OnlineStatus==OS_ONLINE) && (Lines>0) && (!Done))
{
DOOR_WriteText(ANSI_FG_YELLOW " >\033[45C<\033[46D" ANSI_FG_WHITE);
DOOR_GetLine(GL_NODISTURB|GL_EDIT|GL_DISPLAY|GL_HISTORY,'\0',LEN_DIZWIDTH,0,NULL);
if (N_ND->OnlineStatus==OS_ONLINE)
{
if (N_ND->CurrentLine[0]==0) // blank line..
{
Done=TRUE; // finished entering fileid
DOOR_WriteText("\033[A"); //move up 1 line
}
else
{
NewStrNode(N_ND->CurrentLine,FileID); // add line to the list
Lines--;
}
}
}
DOOR_WriteText(ANSI_RESET ANSI_FG_YELLOW " +---------------------------------------------+\r\n" ANSI_FG_WHITE);
}
void SaveID( void ) // *C* add error checking. / create new routine and call it HBBS_SaveFile()
{
HBBS_SaveFile(filename,FileID);
}
void DoorMain(int argc,char *argv[])
{
DOOR_WriteText("\r\n
-=[
Hydra ModifyDIZ V1.1
]=-
=========
-=[
(C) 1996 Deluxe Software Ltd
]=-\r\n\r\n");
if (argc==6 || argc==7)
{
sprintf(outstr,"
Displaying DIZ for file
%-13s
\r\n",argv[2]);
DOOR_WriteText(outstr);
sprintf(filename,"%sWork/%s.DIZ",N_ND->NodeLocation,argv[2]);
if (!(FileID=HBBS_LoadFile(filename)))
{
if (FileID=HBBS_CreateList())
{
DOOR_WriteText("No FileID contained within uploaded file, please enter a new one\r\n");
EditDIZ();
}
}
else
{
DisplayDIZ();
}
if (FileID)
{
// Menu Here...
}
}
else DOOR_WriteText(ANSI_RESET ANSI_FG_RED "Invalid Door Options!\r\n");
if (FileID)
{
SaveID();
FreeStrList(FileID);
}
}
int main(int argc,char *argv[])
{
if (sscanf(argv[1],"%d",&N_NodeNum)==0)
{
printf("Invalid/No Paramaters for door!\n");
exit (20);
}
init("ModifyDIZ");
if (BBSGlobal=HBBS_GimmeBBS())
{
if (N_ND=HBBS_NodeDataPtr(N_NodeNum)) // this should not fail in normal circumstances..
{
DoorMain(argc,argv);
}
}
cleanup(0);
}